package com.jman.message.controller;

import com.jman.message.domain.Message;
import com.jman.message.dto.MessageDTO;
import com.jman.message.service.impl.MessageServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/message")
public class MessageController {
    @Resource
    private MessageServiceImpl messageService;

    @PostMapping("/save")
    public String saveMessage(@RequestBody MessageDTO messageDTO){
        return messageService.saveMessage(messageDTO);
    }

    @GetMapping("/getInfo")
    public List<Message> getMessageInfo(){
        return messageService.list();
    }

    @DeleteMapping("/delInfo")
    public Boolean deleteById(@RequestParam Integer id){
        return messageService.removeById(id);
    }
}
